﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
   
   <Style TargetType="{x:Type RadioButton}">
      <Setter Property="Background"
              Value="{DynamicResource SecondaryBrush}" />
      <Setter Property="BorderBrush"
              Value="{DynamicResource MainBorderBrush}" />
      <Setter Property="MinHeight"
              Value="22" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="ToggleButton">
               <Grid UseLayoutRounding="True"
                     SnapsToDevicePixels="True">
                  <VisualStateManager.VisualStateGroups>
                     <VisualStateGroup  x:Name="CheckStates">
                        <VisualState x:Name="Checked">
                           <Storyboard>
                              <ColorAnimation Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                                              Storyboard.TargetName="PART_Background"
                                              To="{DynamicResource AllGoodColor}"
                                              Duration="0:0:0.2" />
                              <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
                                              Storyboard.TargetName="PART_Background"
                                              To="{DynamicResource ToastAllGoodBorderColor}"
                                              Duration="0:0:0.2" />
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.RenderTransform).(TranslateTransform.X)"
                                                             Storyboard.TargetName="PART_Toggle">
                                 <SplineDoubleKeyFrame KeyTime="0"
                                                       Value="0" />
                                 <SplineDoubleKeyFrame KeyTime="0:0:0.4"
                                                       Value="20"
                                                       KeySpline="0, 1, 0.6, 1" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unchecked">
                           <Storyboard>
                              <ColorAnimation Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                                              Storyboard.TargetName="PART_Background"
                                              To="{DynamicResource SecondaryColor}"
                                              Duration="0:0:0.2" />
                              <ColorAnimation Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
                                              Storyboard.TargetName="PART_Background"
                                              To="{DynamicResource MainBorderColor}"
                                              Duration="0:0:0.2" />
                              <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Ellipse.RenderTransform).(TranslateTransform.X)"
                                                             Storyboard.TargetName="PART_Toggle">
                                 <SplineDoubleKeyFrame KeyTime="0"
                                                       Value="15" />
                                 <SplineDoubleKeyFrame KeyTime="0:0:0.3"
                                                       Value="0"
                                                       KeySpline="0, 0.5, 0.5, 1" />
                              </DoubleAnimationUsingKeyFrames>
                           </Storyboard>
                        </VisualState>
                     </VisualStateGroup>
                     <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Focused">
                           <Storyboard>
                              <DoubleAnimation Duration="0"
                                               Storyboard.TargetName="FocusVisualElement"
                                               Storyboard.TargetProperty="Opacity"
                                               To="1" />
                           </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unfocused" />
                     </VisualStateGroup>
                  </VisualStateManager.VisualStateGroups>
                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="42" />
                     <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>
                  <Border Grid.Column="0"
                          CornerRadius="10"
                          x:Name="PART_Background"
                          Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          BorderThickness="1" />
                  <Canvas Height="20"
                          Grid.Column="0"
                          Margin="2,0,0,0">
                     <Ellipse x:Name="PART_Toggle"
                              Canvas.Left="0"
                              Width="20"
                              Height="20"
                              Fill="White"
                              Stroke="{TemplateBinding BorderBrush}"
                              StrokeThickness="0.3">
                        <Ellipse.RenderTransform>
                           <TranslateTransform X="0"
                                               Y="0" />
                        </Ellipse.RenderTransform>
                        <Ellipse.Effect>
                           <DropShadowEffect BlurRadius="5"
                                             ShadowDepth="0.7"
                                             Direction="270"
                                             Color="#BBBBBB" />
                        </Ellipse.Effect>
                     </Ellipse>
                  </Canvas>
                  <ContentPresenter Content="{TemplateBinding Content}"
                                    VerticalAlignment="Center"
                                    Grid.Column="1"
                                    Margin="5,0,0,0" />
                  <Rectangle Opacity="0"
                             Margin="1"
                             RadiusX="10"
                             RadiusY="10"
                             Width="40"
                             Height="20"
                             Grid.Column="0"
                             StrokeThickness="1"
                             StrokeDashArray="1 2"
                             SnapsToDevicePixels="true"
                             x:Name="FocusVisualElement"
                             Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   
</ResourceDictionary>